/*
 * @Description: 
 * @Version: 2.0
 * @Author: 
 * @Date: 2022-04-08 13:08:33
 * @LastEditors: cxc
 * @LastEditTime: 2022-04-08 16:37:00
 */
import Axios from '../../../utils/myAxios';
export function getDepartAction(data) {
  return {
    type: 'getDepList',
    data
  }
}
export function AsyncGetDepartAction(page, size) {
  return (dispatch) => {
    Axios.get('/department/selectDepartmentList', {
      params: {
        currentPage: page,
        pageSize: size
      }
    })
      .then(res => {
        // console.log(res);
        let newArray = []
        res.data.data.department.forEach(item => {
          newArray.push({
            key: item.id,
            id: item.id,
            departmentName: item.departmentName
          })
        })
        // console.log('new', newArray);
        dispatch(getDepartAction({
          newArray: newArray,
          count: res.data.data.totalCount
        }))
      })
  }
}